package com.tangsm.spring.boot.leaf.controller;

import com.tangsm.spring.boot.leaf.service.IdGeneratorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/id")
public class IdGeneratorController {

    @Autowired
    private IdGeneratorService idGeneratorService;

    @GetMapping("/segment/{bizTag}")
    public Long getSegmentId(@PathVariable String bizTag) {
        return idGeneratorService.generateSegmentId(bizTag);
    }

    @GetMapping("/snowflake")
    public Long getSnowflakeId() {
        return idGeneratorService.generateSnowflakeId();
    }
}